#!/usr/bin/python

from wsgiref.simple_server import make_server
import yaml
import sys
from soapsim.app import SimulatorApp
from soapsim.settings import SimulatorSettings
from soapsim.soaputils import make_fault

USAGE = "python dthought.py CONFIG_FILE"

if __name__ == '__main__':
    if len(sys.argv) != 2:
        print USAGE
        sys.exit(1)
    path = sys.argv[1]
    settings = SimulatorSettings(path)
    app = SimulatorApp(settings)
    print 'Loading simulator configuration from:', path
    print 'Supported operations:'
    print '\n'.join("  %s" % op.soapaction for op in settings.operations)
    print 'Starting simulator [%s] on port %d' % \
          (settings.name, settings.port)
    httpd = make_server('', settings.port, app)
    httpd.serve_forever()
